/**
 * 
 */
package com.easidea.tim.entity.system.permission;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Entity;
import org.springside.core.dao.extend.Undeletable;

import com.easidea.tim.entity.BaseEntity;
import com.easidea.tim.entity.system.orgnization.Staff;

/**
 * @author Harrison
 *
 */
@Entity(dynamicInsert=true,dynamicUpdate=true)
@javax.persistence.Entity(name="tim_permission_role")
@Cache(region="tim_permission_role", usage=CacheConcurrencyStrategy.READ_WRITE)
@Undeletable(status="deleted")
public class Role extends BaseEntity{

	/**
	 * 
	 */
	private static final long serialVersionUID = 6822756012929110183L;

	
	private String name;
	private String memo;
	private List<Permission> permissions;
	private List<Staff> staffList; // 鎷ユ湁瑙掕壊鐨勫垪琛�
	/**
	 * @return the name
	 */
	@Column(name="name", nullable=false)
	public String getName() {
		return name;
	}
	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	/**
	 * @return the memo
	 */
	@Column(name="memo")
	public String getMemo() {
		return memo;
	}
	/**
	 * @param memo the memo to set
	 */
	public void setMemo(String memo) {
		this.memo = memo;
	}
	/**
	 * @return the staffList
	 */
	@ManyToMany(fetch=FetchType.LAZY)
	public List<Staff> getStaffList() {
		return staffList;
	}
	/**
	 * @param staffList the staffList to set
	 */
	public void setStaffList(List<Staff> staffList) {
		this.staffList = staffList;
	}
	/**
	 * @return the permissions
	 */
	@ManyToMany(fetch=FetchType.LAZY,cascade=CascadeType.PERSIST)
	@JoinTable(name="tim_permission_role_permission_rel",
			joinColumns={@JoinColumn(name="role_id",referencedColumnName="id",table="tim_permission_role")},
			inverseJoinColumns={@JoinColumn(name="permission_id",referencedColumnName="id",table="tim_permission_permission")})
	public List<Permission> getPermissions() {
		return permissions;
	}
	/**
	 * @param permissions the permissions to set
	 */
	public void setPermissions(List<Permission> permissions) {
		this.permissions = permissions;
	}
}
